package com.wfx.controller;


import com.wfx.entity.*;
import com.wfx.service.IWxbGoodsCopyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhu
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/copy")
@CrossOrigin
@Api(description = "文案管理")
public class WxbGoodsCopyController {


    @Autowired
    private IWxbGoodsCopyService wxbGoodsCopyService;
    @PostMapping("/search")
    @ApiOperation("文案查询")
    //@PreAuthorize("hasAnyRole('ROLE_COPY')")
    public PageResult<WxbGoodsCopy> search(@RequestBody @ApiParam("文案分页加条件") PageDTO<WxbGoodsCopy> pageDTO){
        System.out.println(pageDTO);
        if (pageDTO == null) {
            pageDTO.setPage(1);
            pageDTO.setLimit(5);
        }
        return wxbGoodsCopyService.findAll(pageDTO);
    }
    @PostMapping("/delSelect")
    @ApiOperation("文案批量删除")
    //@PreAuthorize("hasAnyRole('ROLE_COPY')")
    public Result delByIds(@RequestBody @ApiParam("文案集合") List<WxbGoodsCopy> wxbGoodsCopyList){
        return wxbGoodsCopyService.delSelect(wxbGoodsCopyList);
    }

    @PostMapping("/delOne")
    @ApiOperation("文案删除")
    //@PreAuthorize("hasAnyRole('ROLE_COPY')")
    public Result delOne(@RequestBody @ApiParam("文案实体") WxbGoodsCopy wxbGoodsCopy){
        return wxbGoodsCopyService.deleteGoodCopy(wxbGoodsCopy);
    }
}
